#include "example_interfaces/srv/add_two_ints.hpp"
#include "rclcpp/rclcpp.hpp"
class Server : public rclcpp::Node
{
  private:
	rclcpp::Service<example_interfaces::srv::AddTwoInts>::SharedPtr server;
	void callback(const std::shared_ptr<example_interfaces::srv::AddTwoInts::Request> req,
				  std::shared_ptr<example_interfaces::srv::AddTwoInts::Response> res)
	{
		RCLCPP_INFO(this->get_logger(), "service called: a=%ld, b=%ld", req->a, req->b);
		res->sum = req->a + req->b;
	}

  public:
	Server(std::string name) : Node(name)
	{
		RCLCPP_INFO(this->get_logger(), "Node %s started", name.c_str());
		server = this->create_service<example_interfaces::srv::AddTwoInts>(
			"addservice",
			std::bind(&Server::callback, this, std::placeholders::_1, std::placeholders::_2));
	}
};

int main(int argc, char **argv)
{
	rclcpp::init(argc, argv);
	auto node = std::make_shared<Server>("service_server");
	rclcpp::spin(node);
	rclcpp::shutdown();
	return 0;
}
